package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.Result;
import com.bwie.vo.AttaVo;
import com.bwie.vo.ProdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/5/27 9:27
 * @Version 1.0
 */
@RestController
@RequestMapping("/prod/shop")
public class ProdController {

    @Autowired
    TbProdService tbProdService;

    /**
     * 商品分页列表
     * @param pageVo
     * @return
     */
    @PostMapping("/getProdList")
    public Result getProdList(@RequestBody ProdPageVo pageVo){
        return tbProdService.getProdList(pageVo);
    }

    /**
     * 上传图片
     * @param file
     * @return
     */
    @PostMapping("/loadImage")
    public Result loadImage(@RequestPart("file")MultipartFile file){
        return tbProdService.loadImage(file);
    }

    /**
     * 新增商品
     * @param tbProd
     * @return
     */
    @PostMapping("/addProd")
    public Result addProd(@RequestBody TbProd tbProd){
        return tbProdService.addProd(tbProd);
    }

    /**
     * 批量删除商品
     * @param ids
     * @return
     */
    @PostMapping("/deleteBatchProd")
    public Result deleteBatchProd(@RequestBody List<TbProd> ids){
        return tbProdService.deleteBatch(ids);
    }

    /**
     * 添加商品附件
     * @param attaVo
     * @return
     */
    @PostMapping("/addProdAtta")
    public Result addProdAtta(@RequestBody AttaVo attaVo){
        return tbProdService.addProdAtta(attaVo);
    }
}